package com.hjl.controller;

import com.hjl.common.BaseController;
import com.hjl.common.bean.ResultBean;
import com.hjl.service.UploadService;
import com.hjl.service.impl.UploadServiceImpl;
import com.hjl.vo.FileVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author ServivE
 * @version 0.1
 * @className FileController
 * @description
 * @date 2024/11/18 21:02
 * @since jdk17
 */
@RestController
@RequestMapping("/file")
@Api(tags = "文件管理")
public class FileController extends BaseController {

    @Autowired
    UploadService uploadService;

    @PostMapping("upload")
    @ApiOperation("上传文件")
    public ResultBean upload(@RequestParam("file") MultipartFile file) throws IOException{
        FileVO upload = uploadService.upload(file);
        return success("文件上传成功", upload);

    }
}
